package com.example.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;

import javax.jws.soap.SOAPBinding.Use;

import com.example.dao2.UserDao;
import com.example.dao2.VehicleDao;
import com.example.dao2.UploadPicDao;
import com.example.entity.UploadFile;
import com.example.entity.User;
import com.example.entity.VehicleFaultInfo;
import com.example.utils.DButil;
import com.mysql.jdbc.PreparedStatement;
/**
 * uploadfiletbl表Dao层的实现类 
 * @author Roy
 *
 */
public class UploadPicDaoImpl  implements  UploadPicDao{

public boolean save(UploadFile uf) {
	System.out.println("insert a data to uploadfiletbl");
	String sql="insert into uploadfiletable(id,uploadTime,FileDesc,FilePath)values(?,?,?,?)";
	DButil dbUtil=new DButil();
   Connection connect=	dbUtil.openConnection();
	try {
		java.sql.PreparedStatement pstmt=connect.prepareStatement(sql);
		pstmt.setString(1, uf.getId());
		pstmt.setString(2,uf.getUploadTime());
		pstmt.setString(3,uf.getFileDesc());
		pstmt.setString(4,uf.getFilePath());
	
	//	ResultSet rs=pstmt.executeQuery();
		if (pstmt.executeUpdate()>0) {
			System.out.println("insert a data to uploadfiletbl  success!");
			return true;	
		}
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		System.out.println("insert a data to uploadfiletbl  failed!");
		System.out.println("insert into uploadfiletbl has error: "+e.toString());
		e.printStackTrace();
	}finally{
		dbUtil.closeConn(connect);
	 }
	// TODO Auto-generated method stub
	return false;
}
}
